🤖 perf: rewrite shimmer with pure CSS (no JS animation) #998
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The previous shimmer implementation using Web Worker + OffscreenCanvas still showed 16% CPU usage on the main thread. Even though the animation loop ran in a worker, canvas compositing still hits the main thread.
Solution
Replace with pure CSS using
background-clip: text:color-mix) sweeps acrossbackground-position- no JS involvedWhy this is better
Trade-off
background-positionisn't compositor-only so it does trigger repaints, but for small text elements like "Thinking..." this is negligible compared to the canvas/worker overhead.Files changed
src/browser/components/ai-elements/shimmer.tsx- Pure CSS implementationsrc/browser/styles/globals.css- Added.shimmer-textclass and keyframesrc/browser/workers/shimmerWorker.ts- No longer neededGenerated with
mux